package dk.lector;

import dk.lector.providers.DOC_METADATAContentProvider;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class DashBoardActivity extends BaseFullScreenActivity {
	private String TAG = this.getClass().getSimpleName();

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.dashboard_layout);
		
		try {
		int requestedID = Integer.parseInt(getIntent().getData()
				.getQueryParameter("id"));
			
		Intent getDoc = new Intent(this, DocumentLoaderActivity.class);
		getDoc.putExtra(DOC_METADATAContentProvider._ID, requestedID);
		startActivity(getDoc);
		
		} 	catch (NullPointerException e){};
		
		((Button) findViewById(R.id.home_news))
				.setOnClickListener(new OnClickListener() {
					public void onClick(View v) {
						Intent homeIntent = new Intent(
								DashBoardActivity.this,
								NewsActivity.class);
						homeIntent.setData(getIntent().getData());
						startActivity(homeIntent);
						
					}
				});

		((Button) findViewById(R.id.home_btn_docs))
				.setOnClickListener(new OnClickListener() {

					public void onClick(View v) {
						Intent docsIntent = new Intent(
								DashBoardActivity.this, DocumentsActivity.class);
						docsIntent.setData(getIntent().getData());
						startActivity(docsIntent);
					}
				});

		((Button) findViewById(R.id.home_btn_favorites))
				.setOnClickListener(new OnClickListener() {

					public void onClick(View v) {
						Intent favoritesIntent = new Intent(
								DashBoardActivity.this,
								FavoritesActivity.class);
						favoritesIntent.setData(getIntent().getData());
						startActivity(favoritesIntent);
					}
				});
		((Button) findViewById(R.id.home_btn_search))
				.setOnClickListener(new OnClickListener() {

					public void onClick(View v) {
						Intent searchIntent = new Intent(
								DashBoardActivity.this,
								SearchActivity.class);
						searchIntent.setData(getIntent().getData());
						startActivity(searchIntent);
					}
				});
		((Button) findViewById(R.id.home_btn_configurations))
				.setOnClickListener(new OnClickListener() {

					public void onClick(View v) {
						Intent configIntent = new Intent(
								DashBoardActivity.this,
								PreferenceViewActivity.class);
						configIntent.setData(getIntent().getData());
						startActivity(configIntent);
					}
				});
		
	}

	@Override
	public String actionBarText() {
		// TODO Auto-generated method stub
		return getString(R.string.dashboard_activity_text);
	}
	
	
	
}